#include "Interpolation.h"
#include <iostream>
#include <fstream>
using namespace std;

class Func : public Function
{
public:
    double operator()(double _x)
    {
        double f;
        f = 1 / (1 + _x * _x);
        return f;
    }
};

int main(int argc,char *argv [ ]){
    Func func;
    int n;
    vector<double> X;
    for (int j = 1; j <= 4; j++){
        X.clear();
        n = 2 * j;
        X.push_back(-5.0);
        for (int i = 1; i <= n; i++)
        {
            X.push_back(-5.0 + 10.0 * i / n);
        }
        Newton_formula nf(func, X);
        ofstream ocout;
        ocout.open("questionB.txt", ios::app);
        for (int i = 0; i <= 1000; i++)
        {
            ocout << nf.solve(-5.0 + i * 0.01) << " ";
        }
        ocout << "\n";
        ocout.close();
    }
    return 0;
}
